package com.lsl.menglushishang.android;

import android.app.ListActivity;
import android.content.Context;
import android.database.DataSetObserver;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewGroup.MarginLayoutParams;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.ImageView.ScaleType;

public class RecommendScrollAdapter extends BaseAdapter{
	
	private int[] resourceId = new int[]{};
	
	private Context context;
	
	public RecommendScrollAdapter(Context context){
		this.context = context;
	}
	
	@Override
	public int getCount() {
		return resourceId.length*2;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ImageView image = new ImageView(context);
		image.setImageResource(resourceId[position%resourceId.length]);
		
		WindowManager windowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
		int width = windowManager.getDefaultDisplay().getWidth();
		int height = windowManager.getDefaultDisplay().getHeight();
		
		
		MarginLayoutParams lp =  new MarginLayoutParams((int) (width/3.2),(int) (((width/3.2)*212)/155));
		
		image.setLayoutParams(lp);	
		
		image.setScaleType(ScaleType.FIT_XY);
		return image;
	}

	

}
